package util;

import entity.*;
import factory.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 弃用
 */
@Deprecated
public class Checker {
    private static final Map<CreditCard, CreditCardFactory> maps = new HashMap<>();
    static {
        maps.put(new VisaCC(),VisaFactory.getInstance());
        maps.put(new AmExCC(), AmExFactory.getInstance());
        maps.put(new MasterCC(), MasterFactory.getInstance());
        maps.put(new DiscoverCC(), DiscoverFactory.getInstance());
    }

    public static void check(String line){
        String[] tokens = line.split(" ");
        for(CreditCard card : maps.keySet()){
            if(card.isValid(tokens[0])){
                CreditCard newCard = maps.get(card).createCard(tokens[0], tokens[1]);
                CardCollection.getInstance().addCard(newCard);
            }
        }
    }
}
